import type { R, TableDataInfo } from '@/api/model/resultModel';
import type { XhljGoodsForm, XhljGoodsQuery, XhljGoodsVo } from '@/api/xhlj/model/goodsModel';
import { request } from '@/utils/request';

// 查询商品列表
export function listGoods(query?: XhljGoodsQuery) {
  return request.get<TableDataInfo<XhljGoodsVo>>({
    url: '/xhlj/goods/list',
    params: query,
  });
}

// 查询商品详细
export function getGoods(goodId: number) {
  return request.get<R<XhljGoodsVo>>({
    url: `/xhlj/goods/${goodId}`,
  });
}

// 新增商品
export function addGoods(data: XhljGoodsForm) {
  return request.post<R<void>>({
    url: '/xhlj/goods',
    data,
  });
}

// 修改商品
export function updateGoods(data: XhljGoodsForm) {
  return request.put<R<void>>({
    url: '/xhlj/goods',
    data,
  });
}

// 删除商品
export function delGoods(goodIds: number | Array<number>) {
  return request.delete<R<void>>({
    url: `/xhlj/goods/${goodIds}`,
  });
}
